define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'apply/index' + location.search,
                    add_url: 'apply/add',
                    edit_url: 'apply/edit',
                    del_url: 'apply/del',
                    multi_url: 'apply/multi',
                    returnprice_url: 'apply/retprice',
                    table: 'table',
                },
                commonSearch: false,
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', operate:false,title: __('Id')},
                        {field: 'username', title: __('username'),operate:"like"},
                        {field: 'phone', title: __('phone'),operate:"like"},
                        {field: 'province',operate:false, title: __('province')},
                        {field: 'city',operate:false, title: __('city')},
                        {field: 'area',operate:false, title: __('area')},
                        {field: 'address',operate:false, title: __('address')},
                        {field: 'size',operate:false, title: "房屋面积"},
                        {field: 'count',operate:false, title: "房屋套数"},
                        {field: 'stage', title: __('stage'),operate:false,searchList:{"0":'毛坯',"1":'简装',"2":'精装',"3":'拎包入住'},formatter:Table.api.formatter.normal},
                        {field: 'stage2', title: '房屋房型',operate:false,searchList:{"0":'一室一厅',"1":'两室一厅',"2":'三室一厅',"3":'四室及以上',"4":'单室','99':'未选择'},formatter:Table.api.formatter.normal},
                        {field: 'deal', title: __('deal'),operate:false,searchList:{"0":'未处理',"1":'已处理'},formatter:Table.api.formatter.normal},
                        {field: 'createtime', title: __('createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updtime', title: __('updtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                pagination :false

            });



            // 为表格绑定事件
            Table.api.bindevent(table);
            table.on('post-body.bs.table',function () {
/*
                $(".btn-editone").data("title", "修改订单的信息"); //自定义弹窗标题
                $(".btn-editone").data("area", ["80%","80%"]);//修改弹窗大小*/
            });


        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        setinfo: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));

            }
        }
    };












    return Controller;
});
